<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        html,
        body,
        .vueApp {
            background-color: rgba(0, 0, 0, 0);
            margin: 0;
        }

        .container {
            width: 100vw;
            height: 100vh;
            background-color: rgba(0, 0, 0, 0.5);
        }

        .wrap {
            box-sizing: border-box;
            width: 270px;
            background:rgba(255,255,255,1);
            border-radius:10px;
            padding: 0 10px;
        }

        .title {
            font-size:16px;
            margin-top: 20px;
            font-weight:500;
            color:rgba(63,64,70,1);
            line-height:19px;
            text-align: center;
        }

        .input-email {
            box-sizing: border-box;
            display: block;
            width: 100%;
            height: 38px;
            border-radius: 6px;
            border: 1px solid #BFBFBF;
            font-size: 14px;
            padding: 0 10px;
            margin-top: 15px;
            outline: none;
        }

        .btns {
            position: relative;
            margin-top: 15px;
        }

        .btns::after {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 1px;
            transform: scaleY(0.5);
            background:rgba(226,228,233,1);
        }

        .btn {
            flex-grow: 1;
            height: 50px;
        }

        .btn:first-child {
            font-size:18px;
            font-weight:400;
            color:rgba(127,129,141,1);
            line-height:25px;
            border-right: 1px solid rgba(226,228,233,1);;
        }

        .btn:last-child {
            font-size:18px;
            font-weight:500;
            color:rgba(90,194,255,1);
            line-height:25px;
        }
    </style>
</head>
<body>
    <div class="vueApp" v-cloak>
        <div class="container" data-flex="main:center cross:center">
            <div class="wrap">
                <div class="title">重开发票</div>
                <input class="input-email" v-model="email" placeholder="请输入接收邮箱" type="email">
                <div class="btns" data-flex>
                    <div class="btn" data-flex="main:center cross:center" @click="closeCurrentFrame">取消</div>
                    <div class="btn" data-flex="main:center cross:center" @click="submitRequest">确定</div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm, pageParam;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        pageParam = api.pageParam;
        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                email: ''
            }
        });
    }

    // 关闭当前win
    function closeCurrentFrame() {
        api.closeFrame();
    }

    // 提交请求
    function submitRequest() {
        if(!vm.email) {
            fnToast('邮箱不得为空');
            return;
        };
        if(!/^[a-zA-Z0-9_-]+(\.|[a-zA-Z0-9_-]+)+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(vm.email)) {
            fnToast('邮箱格式错误,请重新输入');
            return;
        };
        var params = {
            orderSn: pageParam.order.orderSn,
            invoiceEmail: vm.email
        };
        var url = 'my/againAddOrderInvoice';
        var callback = function(data) {
            fnToast('提交成功');
            closeCurrentFrame();
        };
        POST(url, params, callback);
    }
</script>
</html>
